package com.zhima.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.zhima.enums.JudgeState;
import com.zhima.enums.ScoreStrategy;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * <p>
 *
 * </p>
 *
 * @author zhima
 * @since 2023-09-05
 */
@Data
@TableName(value = "oj_judge_record", autoResultMap = true)
@ApiModel(value = "OjJudgeRecord对象", description = "")
public class OjJudgeRecord implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("提交记录id")
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    @ApiModelProperty("题目id")
    @TableField("question_id")
    private Long questionId;

    @ApiModelProperty("提交用户id")
    @TableField("user_id")
    private Long userId;

    @ApiModelProperty("提交用户名")
    @TableField("user_name")
    private String userName;

    @ApiModelProperty("提交时间")
    @TableField(value = "submit_time", fill = FieldFill.INSERT)
    private Date submitTime;

    @ApiModelProperty("测评时间")
    @TableField("judge_time")
    private Date judgeTime;

    @ApiModelProperty("评测状态Waiting、Compiling、Complie Error、Judging、Accepted、UnAccepted")
    @TableField("state")
    private JudgeState state;

    @ApiModelProperty("语言")
    @TableField("code_language_id")
    private Integer codeLanguageId;

    @ApiModelProperty("题号")
    @TableField("question_number")
    private String questionNumber;

    @ApiModelProperty("源代码")
    @TableField("source_code")
    private String sourceCode;

    @ApiModelProperty("代码文件大小")
    @TableField("code_size")
    private BigDecimal codeSize;

    @ApiModelProperty("总消耗时间")
    @TableField("use_time")
    private BigDecimal useTime;

    @ApiModelProperty("总消耗内存")
    @TableField("use_memory")
    private BigDecimal useMemory;

    @ApiModelProperty("总得分")
    @TableField("score")
    private Integer score;

    @ApiModelProperty("测评结果，例：[{\"score\": 70, \"scoreStrategy\": \"SUM\", \"testCaseResults\": [{\"time\": 0.149, \"index\": 2, \"score\": 10, \"state\": \"ACCEPTED\", \"memory\": 11512}, {\"time\": 0.16, \"index\": 3, \"score\": 10, \"state\": \"ACCEPTED\", \"memory\": 11752}, {\"time\": 0.153, \"index\": 4, \"score\": 10, \"state\": \"ACCEPTED\", \"memory\": 11552}, {\"time\": 0.162, \"index\": 5, \"score\": 10, \"state\": \"ACCEPTED\", \"memory\": 11704}, {\"time\": 0.168, \"index\": 6, \"score\": 10, \"state\": \"ACCEPTED\", \"memory\": 11764}, {\"time\": 0.163, \"index\": 7, \"score\": 10, \"state\": \"ACCEPTED\", \"memory\": 11620}, {\"time\": 0.159, \"index\": 9, \"score\": 10, \"state\": \"ACCEPTED\", \"memory\": 11704}]}, {\"score\": 30, \"scoreStrategy\": \"MAX\", \"testCaseResults\": [{\"time\": 0.166, \"index\": 0, \"score\": 10, \"state\": \"ACCEPTED\", \"memory\": 11652}, {\"time\": 0.154, \"index\": 1, \"score\": 30, \"state\": \"ACCEPTED\", \"memory\": 12396}, {\"time\": 0.174, \"index\": 8, \"score\": 10, \"state\": \"ACCEPTED\", \"memory\": 11768}]}]")
    @TableField(value = "test_case_results")
    private String testCaseResults;

    @ApiModelProperty("总计分策略")
    @TableField("score_strategy")
    private ScoreStrategy scoreStrategy;

    @ApiModelProperty("如果是比赛中提交的则填入比赛id")
    @TableField("contest_id")
    private Long contestId;

    @ApiModelProperty("本题目在该比赛中的索引")
    @TableField("question_index")
    private Integer questionIndex;

    @ApiModelProperty("ai指导意见")
    @TableField("ai_guide")
    private String aiGuide;
}
